//
//  QLevelCell.m
//  QoilPublic
//
//  Created by 杨凯 on 2017/2/16.
//  Copyright © 2017年 杨凯. All rights reserved.
//

#import "QLevelCell.h"
#import "CardsView.h"
#import "BingdingVC.h"
@interface QLevelCell()
@property (nonatomic,strong)UIButton *cardBtn1;
@property (nonatomic,strong)UIButton *cardBtn2;
@property (nonatomic,strong)UIButton *cardBtn3;

@end

@implementation QLevelCell

- (void)awakeFromNib {
    [super awakeFromNib];
}
-(void)loadViewWithtype:(int)type title:(NSString *)title
{
    if ([title isEqualToString:@""]||title == nil) {
        title = @"绑定";
    }
    _courtLab.hidden = YES;
    _titileLab.hidden = YES;
    _iconImg.hidden = YES;
//    if (type == 1) {
        _titileLab.text = @"绑定提现账户";
        _titileLab.hidden = NO;
        UIButton *button = [UIButton buttonWithType:0];
        button.frame = CGRectMake(self.bounds.size.width-75, self.bounds.size.height/2-15, 60, 30);
        [button setBackgroundImage:[UIImage imageNamed:@"绑定背景"] forState:UIControlStateNormal];
        
        [button setTitle:title forState:UIControlStateNormal];
        button.titleLabel.font  = [UIFont systemFontOfSize: 15];
        button.tag = 10;
        [button addTarget:self action:@selector(TiXianButtonAction:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:button];
//    }
//    if (type == 2) {
//        NSArray *imgArr = @[@"银行卡",@"支付宝",@"微信"];
//        NSArray *titleArr = @[@"银行卡",@"支付宝",@"微信"];
//        for (int i = 0; i<3; i++) {
//            float viewW = self.bounds.size.width/3;
//            float viewH = self.bounds.size.height;
//            float viewX = i*viewW;
//            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(viewX, 0, viewW, viewH)];
//            [self addSubview:view];
//            CardsView *cardView = [[CardsView alloc]initWithFrame:view.bounds];
//            cardView.tag = 100+i;
//            cardView.cImgView.image = [UIImage imageNamed:[imgArr objectAtIndex:i]];
//            [cardView.cButton setImage:[UIImage imageNamed:@"默认圈"] forState:UIControlStateNormal];
//            [cardView.cButton setImage:[UIImage imageNamed:@"选中圈"] forState:UIControlStateSelected];
//            [cardView.cButton addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
//            cardView.cButton.tag = 1000+i;
//            cardView.cLabel.text = [titleArr objectAtIndex:i];
//            [view addSubview:cardView];
//            if (cardView.cButton.tag == 1000) {
//                self.cardBtn1 = cardView.cButton;
//            }
//            if (cardView.cButton.tag == 1001) {
//                self.cardBtn2 = cardView.cButton;
//            }
//            if (cardView.cButton.tag == 1002) {
//                self.cardBtn3 = cardView.cButton;
//            }
//                self.cardBtn1.selected = YES;
//        }
//    }
}
- (void)TiXianButtonAction:(UIButton *)button{
    NSLog(@"绑定");
    UIViewController *vc = [QViewUtility getCurrentVC];
    BingdingVC *bing = [[BingdingVC alloc]init];
    [vc.navigationController pushViewController:bing animated:YES];
    
//    [QViewUtility showAlertViewWithImage:[UIImage imageNamed:@"smile_image"] content:@"该模块尚未开放" btnTitle:showAlertBtnTitle type:1 myBlock:^{}];
//    [self.delegate TiXianDelegateAction];
}
- (void)buttonAction:(UIButton *)button{
    
    if (button.tag == 1000||button.tag == 1001||button.tag == 1002) {
        for (int i = 1000; i<=1002;i++) {
            UIButton *button = (UIButton *)[self viewWithTag:i];
            button.selected = NO;
        }
        button.selected = YES;
    }
     [self.delegate ChooseCardWithType:(int)(button.tag-1000)];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
